import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '提交时间',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '工单类型',
    align:"center",
    dataIndex: 'workOrderType_dictText'
   },
   {
    title: '工单状态',
    align:"center",
    dataIndex: 'workOrderStatus_dictText'
   },
   {
    title: '客户名称',
    align:"center",
    dataIndex: 'customerName'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contacts'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'telephone'
   },
   {
    title: '上门地址',
    align:"center",
    dataIndex: 'homeAddress',
   },
   {
    title: '详细地址',
    align:"center",
    dataIndex: 'address'
   },
   {
    title: '车牌号',
    align:"center",
    dataIndex: 'licensePlate'
   },
   {
    title: '工单描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '预约时间',
    align:"center",
    dataIndex: 'appointmentTime'
   },
   {
    title: '服务时间',
    align:"center",
    sorter: true,
    dataIndex: 'serviceTime'
   },
   {
    title: '结算状态',
    align:"center",
    dataIndex: 'settlementStatus_dictText'
   },
   {
    title: '完成时间',
    align:"center",
    sorter: true,
    dataIndex: 'finishTime'
   },
   {
    title: '优先级',
    align:"center",
    sorter: true,
    dataIndex: 'priority_dictText'
   },
   {
    title: '服务人员',
    align:"center",
    dataIndex: 'serviceStaff_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "联系人",
      field: 'contacts',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系电话",
      field: 'telephone',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "车牌号",
      field: 'licensePlate',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "工单状态",
      field: 'workOrderStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"workOrderStatus"
      },
      //colProps: {span: 6},
 	},
	{
      label: "结算状态",
      field: 'settlementStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"settlementstatus"
      },
      //colProps: {span: 6},
 	},
	{
      label: "是否免费",
      field: 'free',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"free"
      },
      //colProps: {span: 6},
 	},
	{
      label: "服务类型",
      field: 'serviceType',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"serviceType"
      },
      //colProps: {span: 6},
 	},
	{
      label: "优先级",
      field: 'priority',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"workOrderPriority"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '预约时间',
    field: 'appointmentTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
    {
    label: '预约结果',
    field: 'appointmentResults',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表列表数据
export const installationOrderColumns: BasicColumn[] = [
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesman'
   },
   {
    title: '业户名称',
    align:"center",
    dataIndex: 'nameBusinessOwner'
   },
   {
    title: '行驶证照片',
    align:"center",
    dataIndex: 'photoDrivingLicense',
    customRender:render.renderImage,
   },
   {
    title: '车辆类型',
    align:"center",
    dataIndex: 'vehicleType_dictText'
   },
   {
    title: '安装设备',
    align:"center",
    dataIndex: 'installingEquipment_dictText'
   },
   {
    title: '批量安装',
    align:"center",
    dataIndex: 'batchInstallation',
   },
   {
    title: '接入说明',
    align:"center",
    dataIndex: 'accessInstructions_dictText'
   },
];
export const installationOrderFormSchema: FormSchema[] = [
  {
    label: '业务员',
    field: 'salesman',
    component: 'Input',
  },
  {
    label: '业户名称',
    field: 'nameBusinessOwner',
    component: 'Input',
  },
  {
    label: '行驶证照片',
    field: 'photoDrivingLicense',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '车辆类型',
    field: 'vehicleType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"vehicleType"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入车辆类型!'},
          ];
     },
  },
  {
    label: '安装设备',
    field: 'installingEquipment',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"installingEquipment"
     },
  },
  {
    label: '批量安装',
    field: 'batchInstallation',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '接入说明',
    field: 'accessInstructions',
    component: 'JCheckbox',
    componentProps:{
        dictCode:"accessInstructions"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入接入说明!'},
          ];
     },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表表格配置

// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '提交时间',order: 0,view: 'datetime', type: 'string',},
  workOrderType: {title: '工单类型',order: 1,view: 'list', type: 'string',dictCode: 'workOrderType',},
  customerName: {title: '客户名称',order: 2,view: 'text', type: 'string',},
  contacts: {title: '联系人',order: 3,view: 'text', type: 'string',},
  telephone: {title: '联系电话',order: 4,view: 'text', type: 'string',},
  homeAddress: {title: '上门地址',order: 5,view: 'pca', type: 'string',},
  address: {title: '详细地址',order: 6,view: 'text', type: 'string',},
  licensePlate: {title: '车牌号',order: 7,view: 'text', type: 'string',},
  description: {title: '工单描述',order: 8,view: 'textarea', type: 'string',},
  appointmentTime: {title: '预约时间',order: 9,view: 'datetime', type: 'string',},
  serviceTime: {title: '服务时间',order: 10,view: 'datetime', type: 'string',},
  workOrderStatus: {title: '工单状态',order: 11,view: 'number', type: 'number',dictCode: 'workOrderStatus',},
  settlementStatus: {title: '结算状态',order: 12,view: 'number', type: 'number',dictCode: 'settlementstatus',},
  finishTime: {title: '完成时间',order: 15,view: 'datetime', type: 'string',},
  priority: {title: '优先级',order: 16,view: 'number', type: 'number',dictCode: 'workOrderPriority',},
  serviceStaff: {title: '服务人员',order: 17,view: 'sel_user', type: 'string',},
  //子表高级查询
  installationOrder: {
    title: '安装订单',
    view: 'table',
    fields: {
        salesman: {title: '业务员',order: 0,view: 'text', type: 'string',},
        nameBusinessOwner: {title: '业户名称',order: 1,view: 'text', type: 'string',},
        photoDrivingLicense: {title: '行驶证照片',order: 2,view: 'image', type: 'string',},
        vehicleType: {title: '车辆类型',order: 3,view: 'list', type: 'string',dictCode: 'vehicleType',},
        installingEquipment: {title: '安装设备',order: 4,view: 'list', type: 'string',dictCode: 'installingEquipment',},
        batchInstallation: {title: '批量安装',order: 5,view: 'file', type: 'string',},
        accessInstructions: {title: '接入说明',order: 6,view: 'checkbox', type: 'string',dictCode: 'accessInstructions',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}